package com.guigu.dispatch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.guigu.dispatch.entity.OrderClassifyOrder;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.dispatch.mapper.OrderClassifyOrderMapper;
import com.guigu.dispatch.service.OrderClassifyOrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 订单分类订单关联表 服务实现类
 * </p>
 *
 * @author TaoLong
 * @since 2021-11-18
 */
@Transactional
@Service
public class OrderClassifyOrderServiceImpl extends ServiceImpl<OrderClassifyOrderMapper, OrderClassifyOrder> implements OrderClassifyOrderService {


    /**
     * 根据订单Id获取订单分类和订单关联数据的集合
     *
     * @param orderId
     * @return
     */
    @Override
    public List<OrderClassifyOrder> findByOrderId(String orderId) {
        /**
         * 根据订单Id获取所对应的订单分类Id
         */
        QueryWrapper<OrderClassifyOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id",orderId);
        OrderClassifyOrder classifyOrder = baseMapper.selectOne(queryWrapper);

        /**
         * 根据订单分类Id获取订单分类和订单关联数据的集合
         */
        queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("order_classify_id",classifyOrder.getOrderClassifyId());
        List<OrderClassifyOrder> orderClassifyOrderList = baseMapper.selectList(queryWrapper);
        return orderClassifyOrderList;
    }
}
